
#ifndef __ACQUIRE_COMMON_H
#define __ACQUIRE_COMMON_H

#include <stdint.h>

#ifndef __WIN32__
#define EXPORTED
#define EXPORTABI
#else
#ifdef _WINDLL
#define EXPORTED __declspec(dllexport)
#else
#define EXPORTED __declspec(dllimport)
#endif
#define EXPORTABI __cdecl
#endif

#define ACQUIRE_CLIENT_MAX_WAIT 100000

EXPORTED int EXPORTABI acquireCommonStateIsIncomplete();

EXPORTED int EXPORTABI acquireCommonInit(const char *hostname, int portno, const char *senderkeyname,
   const char *my_name, const char *password, const char *recipientkeyname, int is_real_user);

EXPORTED void EXPORTABI acquireCommonInitLibraries();

EXPORTED void EXPORTABI acquireCommonDestroyState();

EXPORTED void EXPORTABI acquireCommonDestroy();

EXPORTED void EXPORTABI acquireCommonClearResults();

EXPORTED int EXPORTABI acquireCommonTestInitialised();

EXPORTED void EXPORTABI acquireCommonSetInitialised();

EXPORTED const char * EXPORTABI acquireCommonCreateDataStore(const char *inputdirectory,
   const char *enckeyname, const char *deckeyname,
   int addspecifickeys, int tblocksize, int64_t *remotespace, int *blocks, int *cancel);

EXPORTED int EXPORTABI acquireCommonDownloadFromDataStore(const char *directory, int blockcount,
   const char *datastoreid, int *cancelflag, const char *decrypterkey);

EXPORTED int EXPORTABI acquireCommonUploadToDataStore(const char *store_id,
   const char *inputdirectory, int tblocksize, int *blocksdone, int *cancelflag, const char *realkeyname);

EXPORTED int EXPORTABI acquireCommonDeferredDownloadFromDataStore(const char *store_id,
   const char *tempdirectory, int blockcount, int *cancelflag);

EXPORTED int EXPORTABI acquireCommonReconstructDeferredDownload(const char *store_id,
   const char *tempdirectory, const char *outputdirectory, int blockcount, const char *realkeyname);

#define ACQUIRE_PURPOSE_RESULT__SUCCESS  1
#define ACQUIRE_PURPOSE_RESULT__ERROR    0
#define ACQUIRE_PURPOSE_RESULT__FAILED  -1
#define ACQUIRE_PURPOSE_RESULT__UNKNOWN -2

EXPORTED int EXPORTABI acquireCommonSetPurposeFlagsOnDataStore(const char *datastoreid,
   int isworkpacket, int isresults,
   const char *clusterid, int maxtimesecs, int instances, const char *ipassword);

#define ACQUIRE_DELETE_DATA_STORE__SUCCESS 0
#define ACQUIRE_DELETE_DATA_STORE__DENIED  1

EXPORTED int EXPORTABI acquireCommonDeleteDataStore(const char *hex_store_id);

EXPORTED const char * EXPORTABI acquireCommonGetParent(const char *actorname);

EXPORTED const char ** EXPORTABI acquireCommonGetChildren(const char *actorname);

struct data_store_info_struct
{
   const char *name;
   const char *decryptionkey;
   int blockcount;
   int blocksize;
   int instancecount;
   int isworkpacket;
   int isresults;
   int iscomplete;
   int isvalid;
};

typedef struct data_store_info_struct acquireCommonDataStoreInfo;

EXPORTED acquireCommonDataStoreInfo EXPORTABI acquireCommonGetDataStoreInformation(const char *datastoreid);

EXPORTED const char * EXPORTABI acquireCommonResolve(const char *hierarchical);

EXPORTED int EXPORTABI acquireCommonChangeTotalBlocks(int change, const char *actorid);

EXPORTED int EXPORTABI acquireCommonChangeDoneBlocks(int change, const char *actorid);

EXPORTED int EXPORTABI acquireCommonAddToTotalBlocks(int change, const char *actorid);

EXPORTED int EXPORTABI acquireCommonAddToDoneBlocks(int change, const char *actorid);

EXPORTED int EXPORTABI acquireCommonSubtractFromTotalBlocks(int change, const char *actorid);

EXPORTED int EXPORTABI acquireCommonSubtractFromDoneBlocks(int change, const char *actorid);

EXPORTED const char * EXPORTABI acquireCommonGetDateTimeStamp();

#endif
